import "descriptor.proto";

extend google.protobuf.FileOptions {
  optional string my_file_option = 50000;
}
extend google.protobuf.MessageOptions {
  optional int32 my_message_option = 50001;
}
extend google.protobuf.FieldOptions {
  optional float my_field_option = 50002;
}
extend google.protobuf.EnumOptions {
  optional bool my_enum_option = 50003;
}
extend google.protobuf.EnumValueOptions {
  optional uint32 my_enum_value_option = 50004;
}
extend google.protobuf.ServiceOptions {
  optional MyEnum my_service_option = 50005;
}
extend google.protobuf.MethodOptions {
  optional MyMessage my_method_option = 50006;
}
package foo;
extend google.protobuf.MessageOptions {
  optional string my_option = 51234;
}

option (my_file_option) = "Hello world!";

message MyMessage {
  option (my_message_option) = 1234;

  optional int32 foo = 1 [(my_field_option) = 4.5];
  optional string bar = 2;
}

enum MyEnum {
  option (my_enum_option) = true; 

  FOO = 1 [(my_enum_value_option) = 321];
  BAR = 2;
} 

message RequestType {}
message ResponseType {}

service MyService {
  option (my_service_option) = FOO;

  rpc MyMethod(RequestType) returns(ResponseType) { 
    // Note:  my_method_option has type MyMessage.  We can set each field
    //   within it using a separate "option" line.
    option (
    my_method_option
    )
    .
    foo = 567; 
    option (my_method_option).bar = "Some string";
  }
}

message FooOptions {
  optional int32 opt1 = 1;
  optional string opt2 = 2;
}

extend google
.
protobuf
.
FieldOptions 
{
  optional FooOptions foo_options = 1234;
}

// usage:
message Bar {
  optional int32 a = 1 [(foo_options).opt1 = 123, (foo_options).opt2 = "baz"];
  // alternative aggregate syntax (uses TextFormat):
  optional 
  int32 
  b 
  = 
  2 
  [(
  foo_options
  ) 
  = 
  { 
  opt1
  : 
  123 
  opt2
  : 
  "baz"
   
   }
   ]
   ;
}

message MyOption 
{
  optional string name = 1;
  optional 
  uint32 
  version 
  = 
  2; 
}

extend google.protobuf.MessageOptions {
  optional
   MyOption 
   my_option2  
   = 
   51555
   ;
}

message MyMessage2
{
  option
   (
   my_option2
   )
   =
    {
    name
     :
      "Me"
    version
     :
      2
  };

  optional
   string
    b
     =
      1
      ;
}